import request from '@/utils/request';
import type { Page, SysSecurity } from '@/types/security';

export interface SecurityData {
  id: number;
  securityName: string;
  contactPhone: string;
  createTime?: string;
  updateTime?: string;
}

export interface SecurityQueryParams {
  securityName?: string;
  contactPhone?: string;
  current: number;
  size: number;
}

export interface ApiResponse<T> {
  code: number;
  message: string;
  data: T;
}

export interface PageResult<T> {
  records: T[];
  total: number;
  size: number;
  current: number;
}

export function getSecurityPage(params: {
  securityName?: string
  contactPhone?: string
  current: number
  size: number
}) {
  return request<Page<SysSecurity>>({
    url: '/api/staff/security/page',
    method: 'get',
    params
  });
}

export function getSecurityById(id: number) {
  return request<SysSecurity>({
    url: `/api/staff/security/${id}`,
    method: 'get'
  });
}

export function addSecurity(data: SysSecurity) {
  return request({
    url: '/api/staff/security',
    method: 'post',
    data
  });
}

export function updateSecurity(data: SysSecurity) {
  return request({
    url: '/api/staff/security',
    method: 'put',
    data
  });
}

export function deleteSecurity(id: number) {
  return request({
    url: `/api/staff/security/${id}`,
    method: 'delete'
  });
}
